package com.gitee.springioc.service.impl;

import com.gitee.springioc.entity.Order;
import com.gitee.springioc.service.OrderService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author ming.yan-1
 * @version V1.0
 * @Title com.gitee.springioc.service.impl
 * @Description
 * @date 2018/9/14  上午11:16
 */
public class OrderServiceImpl implements OrderService {

    public static final Log logger = LogFactory.getLog(OrderServiceImpl.class);

    private ConcurrentHashMap<String, Order> concurrentHashMap = new ConcurrentHashMap<>();

    private String str;

    private List<String> list;

    private Map<String,String> map;

    private Set<String> set;

    @Override
    public void createOrder(String orderNo) {
        System.out.println("into create order method "+orderNo);
    }

    @Override
    public void print() {
        logger.info(this.toString());
    }

    public String getStr() {
        return str;
    }

    public void setStr(String str) {
        this.str = str;
    }

    public List<String> getList() {
        return list;
    }

    public void setList(List<String> list) {
        this.list = list;
    }

    public Map<String, String> getMap() {
        return map;
    }

    public void setMap(Map<String, String> map) {
        this.map = map;
    }

    public Set<String> getSet() {
        return set;
    }

    public void setSet(Set<String> set) {
        this.set = set;
    }

    @Override
    public String toString() {
        return "OrderServiceImpl{" +
                "str='" + str + '\'' +
                ", list=" + list +
                ", map=" + map +
                ", set=" + set +
                '}';
    }

    public void init(){
        logger.info("执行OrderServiceImpl的init方法");
        for(int i = 0;i<15;i++){
            Order o1 = new Order();
            o1.setHomeAddress("i am "+i+" home address");
            o1.setName("i am "+i);
            concurrentHashMap.put("order"+i,o1);
        }
    }

    @Override
    public ConcurrentHashMap<String, Order> getCache() {
        return concurrentHashMap;
    }
}
